package name.gillier.jminify.models;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.datastore.Link;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Lien {
	
	public Lien(String url, String title) {
		this.url = new Link(url);
		this.title = title;
		this.dateInsertion = new Date();
	}

	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
	
	@Persistent
	private Link url;
	
	@Persistent
	private String title;
	
	@Persistent
	private Date dateInsertion;

	/**
	 * Getters & setters 
	 */
	
	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}

	public void setDateInsertion(Date dateInsertion) {
		this.dateInsertion = dateInsertion;
	}

	public Date getDateInsertion() {
		return dateInsertion;
	}

	public void setUrl(Link url) {
		this.url = url;
	}

	public String getUrl() {
		return url.toString();
	}
	
}
